Nightly Per-Antenna Quality Summary Notebook¶

Josh Dillon, Last Revised February 2021

This notebooks brings together as much information as possible from ant_metrics, auto_metrics and redcal to help figure out which antennas are working properly and summarizes it in a single giant table. It is meant to be lightweight and re-run as often as necessary over the night, so it can be run when any of those is done and then be updated when another one completes.

Contents:¶

  • Table 1: Overall Array Health
  • Table 2: RTP Per-Antenna Metrics Summary Table
  • Figure 1: Array Plot of Flags and A Priori Statuses
In [1]:
import os
os.environ['HDF5_USE_FILE_LOCKING'] = 'FALSE'
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
import pandas as pd
pd.set_option('display.max_rows', 1000)
from hera_qm.metrics_io import load_metric_file
from hera_cal import utils, io, redcal
import glob
import h5py
from copy import deepcopy
from IPython.display import display, HTML
from hera_notebook_templates.utils import status_colors
from hera_mc import mc
from pyuvdata import UVData

%matplotlib inline
%config InlineBackend.figure_format = 'retina'
display(HTML("<style>.container { width:100% !important; }</style>"))
In [2]:
# If you want to run this notebook locally, copy the output of the next cell into the first few lines of this cell.

# JD = "2459122"
# data_path = '/lustre/aoc/projects/hera/H4C/2459122'
# ant_metrics_ext = ".ant_metrics.hdf5"
# redcal_ext = ".maybe_good.omni.calfits"
# nb_outdir = '/lustre/aoc/projects/hera/H4C/h4c_software/H4C_Notebooks/_rtp_summary_'
# good_statuses = "digital_ok,calibration_maintenance,calibration_triage,calibration_ok"
# os.environ["JULIANDATE"] = JD
# os.environ["DATA_PATH"] = data_path
# os.environ["ANT_METRICS_EXT"] = ant_metrics_ext
# os.environ["REDCAL_EXT"] = redcal_ext
# os.environ["NB_OUTDIR"] = nb_outdir
# os.environ["GOOD_STATUSES"] = good_statuses
In [3]:
# Use environment variables to figure out path to data
JD = os.environ['JULIANDATE']
data_path = os.environ['DATA_PATH']
ant_metrics_ext = os.environ['ANT_METRICS_EXT']
redcal_ext = os.environ['REDCAL_EXT']
nb_outdir = os.environ['NB_OUTDIR']
good_statuses = os.environ['GOOD_STATUSES']
print(f'JD = "{JD}"')
print(f'data_path = "{data_path}"')
print(f'ant_metrics_ext = "{ant_metrics_ext}"')
print(f'redcal_ext = "{redcal_ext}"')
print(f'nb_outdir = "{nb_outdir}"')
print(f'good_statuses = "{good_statuses}"')
JD = "2459826"
data_path = "/mnt/sn1/2459826"
ant_metrics_ext = ".ant_metrics.hdf5"
redcal_ext = ".known_good.omni.calfits"
nb_outdir = "/home/obs/src/H6C_Notebooks/_rtp_summary_"
good_statuses = "digital_ok,calibration_maintenance,calibration_triage,calibration_ok"
In [4]:
from astropy.time import Time
utc = Time(JD, format='jd').datetime
print(f'Date: {utc.month}-{utc.day}-{utc.year}')
Date: 9-3-2022
In [5]:
# Per-season options
def ant_to_report_url(ant):
    return f'https://htmlpreview.github.io/?https://github.com/HERA-Team/H6C_Notebooks/blob/main/antenna_report/antenna_{ant}_report.html'

Load Auto Metrics¶

In [6]:
use_auto_metrics = False

# find the auto_metrics file
glob_str = os.path.join(data_path, f'zen.{JD}*.auto_metrics.h5')
auto_metrics_file = sorted(glob.glob(glob_str))

# if it exists, load and extract relevant information
if len(auto_metrics_file) > 0:
    auto_metrics_file = auto_metrics_file[0]
    print(f'Found auto_metrics results file at {auto_metrics_file}.')
    
    auto_metrics = load_metric_file(auto_metrics_file)
    mean_round_modz_cut = auto_metrics['parameters']['mean_round_modz_cut']
    auto_ex_ants = auto_metrics['ex_ants']['r2_ex_ants']
    
    use_auto_metrics = True
else:
    print(f'No files found matching glob {glob_str}. Skipping auto_metrics.')
Found auto_metrics results file at /mnt/sn1/2459826/zen.2459826.25305.sum.auto_metrics.h5.

Load Ant Metrics¶

In [7]:
use_ant_metrics = False

# get a list of all ant_metrics files
glob_str = os.path.join(data_path, f'zen.{JD}.?????.sum{ant_metrics_ext}')
ant_metrics_files = sorted(glob.glob(glob_str))

# if they exist, load as many of them as possible
if len(ant_metrics_files) > 0:
    print(f'Found {len(ant_metrics_files)} ant_metrics files matching glob {glob_str}')
    ant_metrics_apriori_exants = {}
    ant_metrics_xants_dict = {}
    ant_metrics_dead_ants_dict = {}
    ant_metrics_crossed_ants_dict = {}
    ant_metrics_dead_metrics = {}
    ant_metrics_crossed_metrics = {}
    dead_cuts = {}
    crossed_cuts = {}
    for amf in ant_metrics_files:
        with h5py.File(amf, "r") as infile: # use h5py directly since it's much faster than load_metric_file
            # get out results for this file
            dead_cuts[amf] = infile['Metrics']['dead_ant_cut'][()]
            crossed_cuts[amf] = infile['Metrics']['cross_pol_cut'][()]
            xants = infile['Metrics']['xants'][:]
            dead_ants = infile['Metrics']['dead_ants'][:]
            crossed_ants = infile['Metrics']['crossed_ants'][:]        
            try:
                # look for ex_ants in history
                ex_ants_string = infile['Header']['history'][()].decode()
                ex_ants_string = ex_ants_string.split('--apriori_xants')[1]
                ex_ants_string = ex_ants_string.split('--')[0].strip()
            except:
                ex_ants_string = ''
                    
            # This only works for the new correlation-matrix-based ant_metrics
            if 'corr' in infile['Metrics']['final_metrics'] and 'corrXPol' in infile['Metrics']['final_metrics']:
                ant_metrics_dead_metrics[amf] = {eval(ant): infile['Metrics']['final_metrics']['corr'][ant][()]
                                                 for ant in infile['Metrics']['final_metrics']['corr']}
                ant_metrics_crossed_metrics[amf] = {eval(ant): infile['Metrics']['final_metrics']['corrXPol'][ant][()]
                                                    for ant in infile['Metrics']['final_metrics']['corrXPol']}                       
            else:
                raise(KeywordError)
        
        # organize results by file
        ant_metrics_xants_dict[amf] = [(int(ant[0]), ant[1].decode()) for ant in xants]
        ant_metrics_dead_ants_dict[amf] = [(int(ant[0]), ant[1].decode()) for ant in dead_ants]
        ant_metrics_crossed_ants_dict[amf] = [(int(ant[0]), ant[1].decode()) for ant in crossed_ants]
        ant_metrics_apriori_exants[amf] = [int(ant) for ant in ex_ants_string.split()]
    
    dead_cut = np.median(list(dead_cuts.values()))
    crossed_cut = np.median(list(crossed_cuts.values()))
        
    use_ant_metrics = True
else:
    print(f'No files found matching glob {glob_str}. Skipping ant_metrics.')
Found 292 ant_metrics files matching glob /mnt/sn1/2459826/zen.2459826.?????.sum.ant_metrics.hdf5

Load chi^2 info from redcal¶

In [8]:
use_redcal = False
glob_str = os.path.join(data_path, f'zen.{JD}.?????.sum{redcal_ext}')

redcal_files = sorted(glob.glob(glob_str))
if len(redcal_files) > 0:
    print(f'Found {len(redcal_files)} ant_metrics files matching glob {glob_str}')
    post_redcal_ant_flags_dict = {}
    flagged_by_redcal_dict = {}
    cspa_med_dict = {}
    for cal in redcal_files:
        hc = io.HERACal(cal)
        _, flags, cspa, chisq = hc.read()
        cspa_med_dict[cal] = {ant: np.nanmedian(cspa[ant], axis=1) for ant in cspa}

        post_redcal_ant_flags_dict[cal] = {ant: np.all(flags[ant]) for ant in flags}
        # check history to distinguish antennas flagged going into redcal from ones flagged during redcal
        tossed_antenna_lines =  hc.history.replace('\n','').split('Throwing out antenna ')[1:]
        flagged_by_redcal_dict[cal] = sorted([int(line.split(' ')[0]) for line in tossed_antenna_lines])
        
    use_redcal = True
else:
    print(f'No files found matching glob {glob_str}. Skipping redcal chisq.')
No files found matching glob /mnt/sn1/2459826/zen.2459826.?????.sum.known_good.omni.calfits. Skipping redcal chisq.

Figure out some general properties¶

In [9]:
# Parse some general array properties, taking into account the fact that we might be missing some of the metrics
ants = []
pols = []
antpol_pairs = []

if use_auto_metrics:
    ants = sorted(set(bl[0] for bl in auto_metrics['modzs']['r2_shape_modzs']))
    pols = sorted(set(bl[2] for bl in auto_metrics['modzs']['r2_shape_modzs']))
if use_ant_metrics:
    antpol_pairs = sorted(set([antpol for dms in ant_metrics_dead_metrics.values() for antpol in dms.keys()]))
    antpols = sorted(set(antpol[1] for antpol in antpol_pairs))
    ants = sorted(set(antpol[0] for antpol in antpol_pairs) | set(ants))
    pols = sorted(set(utils.join_pol(ap, ap) for ap in antpols) | set(pols))
if use_redcal:
    antpol_pairs = sorted(set([ant for cspa in cspa_med_dict.values() for ant in cspa.keys()]) | set(antpol_pairs))
    antpols = sorted(set(antpol[1] for antpol in antpol_pairs))
    ants = sorted(set(antpol[0] for antpol in antpol_pairs) | set(ants))
    pols = sorted(set(utils.join_pol(ap, ap) for ap in antpols) | set(pols))

# Figure out remaining antennas not in data and also LST range
data_files = sorted(glob.glob(os.path.join(data_path, 'zen.*.sum.uvh5')))
hd = io.HERAData(data_files[0])
unused_ants = [ant for ant in hd.antpos if ant not in ants]    
hd_last = io.HERAData(data_files[-1])

Load a priori antenna statuses and node numbers¶

In [10]:
# try to load a priori antenna statusesm but fail gracefully if this doesn't work.
a_priori_statuses = {ant: 'Not Found' for ant in ants}
nodes = {ant: np.nan for ant in ants + unused_ants}
try:
    from hera_mc import cm_hookup

    # get node numbers
    hookup = cm_hookup.get_hookup('default')
    for ant_name in hookup:
        ant = int("".join(filter(str.isdigit, ant_name)))
        if ant in nodes:
            if hookup[ant_name].get_part_from_type('node')['E<ground'] is not None:
                nodes[ant] = int(hookup[ant_name].get_part_from_type('node')['E<ground'][1:])
    
    # get apriori antenna status
    for ant_name, data in hookup.items():
        ant = int("".join(filter(str.isdigit, ant_name)))
        if ant in a_priori_statuses:
            a_priori_statuses[ant] = data.apriori

except Exception as err:
    print(f'Could not load node numbers and a priori antenna statuses.\nEncountered {type(err)} with message: {err}')

Summarize auto metrics¶

In [11]:
if use_auto_metrics:
    # Parse modzs
    modzs_to_check = {'Shape': 'r2_shape_modzs', 'Power': 'r2_power_modzs', 
                      'Temporal Variability': 'r2_temp_var_modzs', 'Temporal Discontinuties': 'r2_temp_diff_modzs'}
    worst_metrics = []
    worst_zs = []
    all_modzs = {}
    binary_flags = {rationale: [] for rationale in modzs_to_check}

    for ant in ants:
        # parse modzs and figure out flag counts
        modzs = {f'{pol} {rationale}': auto_metrics['modzs'][dict_name][(ant, ant, pol)] 
                 for rationale, dict_name in modzs_to_check.items() for pol in pols}
        for pol in pols:
            for rationale, dict_name in modzs_to_check.items():
                binary_flags[rationale].append(auto_metrics['modzs'][dict_name][(ant, ant, pol)] > mean_round_modz_cut)

        # parse out all metrics for dataframe
        for k in modzs:
            col_label = k + ' Modified Z-Score'
            if col_label in all_modzs:
                all_modzs[col_label].append(modzs[k])
            else:
                all_modzs[col_label] = [modzs[k]]
                
    mean_round_modz_cut = auto_metrics['parameters']['mean_round_modz_cut']
else:
    mean_round_modz_cut = 0

Summarize ant metrics¶

In [12]:
if use_ant_metrics:
    a_priori_flag_frac = {ant: np.mean([ant in apxa for apxa in ant_metrics_apriori_exants.values()]) for ant in ants}
    dead_ant_frac = {ap: {ant: np.mean([(ant, ap) in das for das in ant_metrics_dead_ants_dict.values()])
                                 for ant in ants} for ap in antpols}
    crossed_ant_frac = {ant: np.mean([np.any([(ant, ap) in cas for ap in antpols])
                                      for cas in ant_metrics_crossed_ants_dict.values()]) for ant in ants}
    ant_metrics_xants_frac_by_antpol = {antpol: np.mean([antpol in amx for amx in ant_metrics_xants_dict.values()]) for antpol in antpol_pairs}
    ant_metrics_xants_frac_by_ant = {ant: np.mean([np.any([(ant, ap) in amx for ap in antpols])
                                     for amx in ant_metrics_xants_dict.values()]) for ant in ants}
    average_dead_metrics = {ap: {ant: np.nanmean([dm.get((ant, ap), np.nan) for dm in ant_metrics_dead_metrics.values()]) 
                                 for ant in ants} for ap in antpols}
    average_crossed_metrics = {ant: np.nanmean([cm.get((ant, ap), np.nan) for ap in antpols 
                                                for cm in ant_metrics_crossed_metrics.values()]) for ant in ants}
else:
    dead_cut = 0.4
    crossed_cut = 0.0

Summarize redcal chi^2 metrics¶

In [13]:
if use_redcal:
    cspa = {ant: np.nanmedian(np.hstack([cspa_med_dict[cal][ant] for cal in redcal_files])) for ant in antpol_pairs}
    redcal_prior_flag_frac = {ant: np.mean([np.any([afd[ant, ap] and not ant in flagged_by_redcal_dict[cal] for ap in antpols])
                                            for cal, afd in post_redcal_ant_flags_dict.items()]) for ant in ants}
    redcal_flagged_frac = {ant: np.mean([ant in fbr for fbr in flagged_by_redcal_dict.values()]) for ant in ants}

Get FEM switch states¶

In [14]:
HHautos = sorted(glob.glob(f"{data_path}/zen.{JD}.*.sum.autos.uvh5"))
diffautos = sorted(glob.glob(f"{data_path}/zen.{JD}.*.diff.autos.uvh5"))

try:
    db = mc.connect_to_mc_db(None)
    session = db.sessionmaker()
    startJD = float(HHautos[0].split('zen.')[1].split('.sum')[0])
    stopJD = float(HHautos[-1].split('zen.')[1].split('.sum')[0])
    startTime = Time(startJD,format='jd')
    stopTime = Time(stopJD,format='jd')
    res = session.get_antenna_status(starttime=startTime, stoptime=stopTime)
    fem_switches = {}
    if len(res) == 0:
        femState = None
    else:
        for antpol in res:
            fem_switches[(antpol.antenna_number, antpol.antenna_feed_pol)] = antpol.fem_switch
    femState = (max(set(list(fem_switches.values())), key = list(fem_switches.values()).count)) 
except Exception as e:
    print(e)
    femState = None

Find X-engine Failures¶

In [15]:
read_inds = [1, len(HHautos)//2, -2]
x_status = [1,1,1,1,1,1,1,1]
s = UVData()
s.read(HHautos[1])

nants = len(s.get_ants())
freqs = s.freq_array[0]*1e-6
nfreqs = len(freqs)

antCon = {a: None for a in ants}
rightAnts = []
for i in read_inds:
    s = UVData()
    d = UVData()
    s.read(HHautos[i])
    d.read(diffautos[i])
    for pol in [0,1]:
        sm = np.abs(s.data_array[:,0,:,pol])
        df = np.abs(d.data_array[:,0,:,pol])
        sm = np.r_[sm, np.nan + np.zeros((-len(sm) % nants,len(freqs)))]
        sm = np.nanmean(sm.reshape(-1,nants,nfreqs),axis=1)
        df = np.r_[df, np.nan + np.zeros((-len(df) % nants,len(freqs)))]
        df = np.nanmean(df.reshape(-1,nants,nfreqs),axis=1)

        evens = (sm + df)/2
        odds = (sm - df)/2
        rat = np.divide(evens,odds)
        rat = np.nan_to_num(rat)
        for xbox in range(0,8):
            xavg = np.nanmean(rat[:,xbox*192:(xbox+1)*192],axis=1)
            if np.nanmax(xavg)>1.5 or np.nanmin(xavg)<0.5:
                x_status[xbox] = 0
    for ant in ants:
        for pol in ["xx", "yy"]:
            if antCon[ant] is False:
                continue
            spectrum = s.get_data(ant, ant, pol)
            stdev = np.std(spectrum)
            med = np.median(np.abs(spectrum))
            if (femState == "load" or femState == 'noise') and 80000 < stdev <= 4000000 and antCon[ant] is not False:
                antCon[ant] = True
            elif femState == "antenna" and stdev > 500000 and med > 950000 and antCon[ant] is not False:
                antCon[ant] = True
            else:
                antCon[ant] = False
            if np.min(np.abs(spectrum)) < 100000:
                antCon[ant] = False
for ant in ants:
    if antCon[ant] is True:
        rightAnts.append(ant)
            
x_status_str = ''
for i,x in enumerate(x_status):
    if x==0:
        x_status_str += '\u274C '
    else:
        x_status_str += '\u2705 '

Build Overall Health DataFrame¶

In [16]:
def comma_sep_paragraph(vals, chars_per_line=40):
    outstrs = []
    for val in vals:
        if (len(outstrs) == 0) or (len(outstrs[-1]) > chars_per_line):
            outstrs.append(str(val))
        else:
            outstrs[-1] += ', ' + str(val)
    return ',<br>'.join(outstrs)
In [17]:
# Time data
to_show = {'JD': [JD]}
to_show['Date'] = f'{utc.month}-{utc.day}-{utc.year}'
to_show['LST Range'] = f'{hd.lsts[0] * 12 / np.pi:.3f} -- {hd_last.lsts[-1] * 12 / np.pi:.3f} hours'

# X-engine status
to_show['X-Engine Status'] = x_status_str

# Files
to_show['Number of Files'] = len(data_files)

# Antenna Calculations
to_show['Total Number of Antennas'] = len(ants)

to_show[' '] = ''
to_show['OPERATIONAL STATUS SUMMARY'] = ''

status_count = {status: 0 for status in status_colors}
for ant, status in a_priori_statuses.items():
    if status in status_count:
        status_count[status] = status_count[status] + 1
    else:
        status_count[status] = 1
to_show['Antenna A Priori Status Count'] = '<br>'.join([f'{status}: {status_count[status]}' for status in status_colors if status in status_count and status_count[status] > 0])

to_show['Commanded Signal Source'] = femState
to_show['Antennas in Commanded State'] = f'{len(rightAnts)} / {len(ants)} ({len(rightAnts) / len(ants):.1%})'

if use_ant_metrics:
    to_show['Cross-Polarized Antennas'] = ', '.join([str(ant) for ant in ants if (np.max([dead_ant_frac[ap][ant] for ap in antpols]) + crossed_ant_frac[ant] == 1) 
                                                                                 and (crossed_ant_frac[ant] > .5)])

# Node calculations
nodes_used = set([nodes[ant] for ant in ants if np.isfinite(nodes[ant])])
to_show['Total Number of Nodes'] = len(nodes_used)
if use_ant_metrics:
    node_off = {node: True for node in nodes_used}
    not_correlating = {node: True for node in nodes_used}
    for ant in ants:
        for ap in antpols:
            if np.isfinite(nodes[ant]):
                if np.isfinite(average_dead_metrics[ap][ant]):
                    node_off[nodes[ant]] = False
                if dead_ant_frac[ap][ant] < 1:
                    not_correlating[nodes[ant]] = False
    to_show['Nodes Registering 0s'] = ', '.join([f'N{n:02}' for n in sorted([node for node in node_off if node_off[node]])])
    to_show['Nodes Not Correlating'] = ', '.join([f'N{n:02}' for n in sorted([node for node in not_correlating if not_correlating[node] and not node_off[node]])])

# Pipeline calculations    
to_show['  '] = ''
to_show['NIGHTLY ANALYSIS SUMMARY'] = ''
    
all_flagged_ants = []
if use_ant_metrics:
    to_show['Ant Metrics Done?'] = '\u2705'
    ant_metrics_flagged_ants = [ant for ant in ants if ant_metrics_xants_frac_by_ant[ant] > 0]
    all_flagged_ants.extend(ant_metrics_flagged_ants)
    to_show['Ant Metrics Flagged Antennas'] = f'{len(ant_metrics_flagged_ants)} / {len(ants)} ({len(ant_metrics_flagged_ants) / len(ants):.1%})' 
else:
    to_show['Ant Metrics Done?'] = '\u274C'
if use_auto_metrics:
    to_show['Auto Metrics Done?'] = '\u2705'
    auto_metrics_flagged_ants = [ant for ant in ants if ant in auto_ex_ants]
    all_flagged_ants.extend(auto_metrics_flagged_ants)    
    to_show['Auto Metrics Flagged Antennas'] = f'{len(auto_metrics_flagged_ants)} / {len(ants)} ({len(auto_metrics_flagged_ants) / len(ants):.1%})' 
else:
    to_show['Auto Metrics Done?'] = '\u274C'
if use_redcal:
    to_show['Redcal Done?'] = '\u2705'    
    redcal_flagged_ants = [ant for ant in ants if redcal_flagged_frac[ant] > 0]
    all_flagged_ants.extend(redcal_flagged_ants)    
    to_show['Redcal Flagged Antennas'] = f'{len(redcal_flagged_ants)} / {len(ants)} ({len(redcal_flagged_ants) / len(ants):.1%})' 
else:
    to_show['Redcal Done?'] = '\u274C' 
to_show['Never Flagged Antennas'] = f'{len(ants) - len(set(all_flagged_ants))} / {len(ants)} ({(len(ants) - len(set(all_flagged_ants))) / len(ants):.1%})'

# Count bad antennas with good statuses and vice versa
n_apriori_good = len([ant for ant in ants if a_priori_statuses[ant] in good_statuses.split(',')])
apriori_good_flagged = []
aprior_bad_unflagged = []
for ant in ants:
    if ant in set(all_flagged_ants) and a_priori_statuses[ant] in good_statuses.split(','):
        apriori_good_flagged.append(ant)
    elif ant not in set(all_flagged_ants) and a_priori_statuses[ant] not in good_statuses.split(','):
        aprior_bad_unflagged.append(ant)
to_show['A Priori Good Antennas Flagged'] = f'{len(apriori_good_flagged)} / {n_apriori_good} total a priori good antennas:<br>' + \
                                            comma_sep_paragraph(apriori_good_flagged)
to_show['A Priori Bad Antennas Not Flagged'] = f'{len(aprior_bad_unflagged)} / {len(ants) - n_apriori_good} total a priori bad antennas:<br>' + \
                                            comma_sep_paragraph(aprior_bad_unflagged)

# Apply Styling
df = pd.DataFrame(to_show)
divider_cols = [df.columns.get_loc(col) for col in ['NIGHTLY ANALYSIS SUMMARY', 'OPERATIONAL STATUS SUMMARY']]
try:
    to_red_columns = [df.columns.get_loc(col) for col in ['Cross-Polarized Antennas', 'Nodes Registering 0s', 
                                                          'Nodes Not Correlating', 'A Priori Good Antennas Flagged']]
except:
    to_red_columns = []
def red_specific_cells(x):
    df1 = pd.DataFrame('', index=x.index, columns=x.columns)
    for col in to_red_columns:
        df1.iloc[col] = 'color: red'
    return df1

df = df.T
table = df.style.hide_columns().apply(red_specific_cells, axis=None)
for col in divider_cols:
    table = table.set_table_styles([{"selector":f"tr:nth-child({col+1})", "props": [("background-color", "black"), ("color", "white")]}], overwrite=False)

Table 1: Overall Array Health¶

In [18]:
HTML(table.render())
Out[18]:
JD 2459826
Date 9-3-2022
LST Range 18.357 -- 20.357 hours
X-Engine Status ✅ ✅ ✅ ✅ ✅ ✅ ✅ ✅
Number of Files 372
Total Number of Antennas 147
OPERATIONAL STATUS SUMMARY
Antenna A Priori Status Count dish_maintenance: 3
RF_maintenance: 32
RF_ok: 11
digital_maintenance: 3
digital_ok: 95
not_connected: 3
Commanded Signal Source None
Antennas in Commanded State 0 / 147 (0.0%)
Cross-Polarized Antennas
Total Number of Nodes 15
Nodes Registering 0s N18
Nodes Not Correlating N02, N04, N12
NIGHTLY ANALYSIS SUMMARY
Ant Metrics Done? ✅
Ant Metrics Flagged Antennas 64 / 147 (43.5%)
Auto Metrics Done? ✅
Auto Metrics Flagged Antennas 113 / 147 (76.9%)
Redcal Done? ❌
Never Flagged Antennas 22 / 147 (15.0%)
A Priori Good Antennas Flagged 74 / 95 total a priori good antennas:
5, 7, 9, 10, 16, 19, 20, 21, 30, 31, 37, 38,
40, 41, 42, 45, 53, 54, 55, 56, 67, 68, 69,
71, 72, 73, 81, 83, 84, 86, 88, 91, 93, 94,
98, 99, 100, 101, 103, 105, 106, 107, 108,
111, 117, 118, 121, 122, 123, 130, 140, 141,
142, 144, 156, 157, 158, 160, 161, 165, 167,
169, 170, 176, 177, 178, 179, 181, 183, 185,
186, 187, 189, 190
A Priori Bad Antennas Not Flagged 1 / 52 total a priori bad antennas:
90
In [19]:
# write to csv
outpath = os.path.join(nb_outdir, f'array_health_table_{JD}.csv')
print(f'Now saving Table 2 to a csv at {outpath}')
df.replace({'\u2705': 'Y'}, regex=True).replace({'\u274C': 'N'}, regex=True).replace({'<br>': ' '}, regex=True).to_csv(outpath)
Now saving Table 2 to a csv at /home/obs/src/H6C_Notebooks/_rtp_summary_/array_health_table_2459826.csv

Build DataFrame¶

In [20]:
# build dataframe
to_show = {'Ant': [f'<a href="{ant_to_report_url(ant)}" target="_blank">{ant}</a>' for ant in ants],
           'Node': [f'N{nodes[ant]:02}' for ant in ants], 
           'A Priori Status': [a_priori_statuses[ant] for ant in ants]}
           #'Worst Metric': worst_metrics, 'Worst Modified Z-Score': worst_zs}
df = pd.DataFrame(to_show)

# create bar chart columns for flagging percentages:
bar_cols = {}
if use_auto_metrics:
    bar_cols['Auto Metrics Flags'] = [float(ant in auto_ex_ants) for ant in ants]
if use_ant_metrics:
    if np.sum(list(a_priori_flag_frac.values())) > 0:  # only include this col if there are any a priori flags
        bar_cols['A Priori Flag Fraction in Ant Metrics'] = [a_priori_flag_frac[ant] for ant in ants]
    for ap in antpols:
        bar_cols[f'Dead Fraction in Ant Metrics ({ap})'] = [dead_ant_frac[ap][ant] for ant in ants]
    bar_cols['Crossed Fraction in Ant Metrics'] = [crossed_ant_frac[ant] for ant in ants]
if use_redcal:
    bar_cols['Flag Fraction Before Redcal'] = [redcal_prior_flag_frac[ant] for ant in ants]
    bar_cols['Flagged By Redcal chi^2 Fraction'] = [redcal_flagged_frac[ant] for ant in ants]  
for col in bar_cols:
    df[col] = bar_cols[col]

# add auto_metrics
if use_auto_metrics:
    for label, modz in all_modzs.items():
        df[label] = modz
z_score_cols = [col for col in df.columns if 'Modified Z-Score' in col]        
        
# add ant_metrics
ant_metrics_cols = {}
if use_ant_metrics:
    for ap in antpols:
        ant_metrics_cols[f'Average Dead Ant Metric ({ap})'] = [average_dead_metrics[ap][ant] for ant in ants]
    ant_metrics_cols['Average Crossed Ant Metric'] = [average_crossed_metrics[ant] for ant in ants]
    for col in ant_metrics_cols:
        df[col] = ant_metrics_cols[col]   

# add redcal chisq
redcal_cols = []
if use_redcal:
    for ap in antpols:
        col_title = f'Median chi^2 Per Antenna ({ap})'
        df[col_title] = [cspa[ant, ap] for ant in ants]
        redcal_cols.append(col_title)

# sort by node number and then by antenna number within nodes
df.sort_values(['Node', 'Ant'], ascending=True)

# style dataframe
table = df.style.hide_index()\
          .applymap(lambda val: f'background-color: {status_colors[val]}' if val in status_colors else '', subset=['A Priori Status']) \
          .background_gradient(cmap='viridis', vmax=mean_round_modz_cut * 3, vmin=0, axis=None, subset=z_score_cols) \
          .background_gradient(cmap='bwr_r', vmin=dead_cut-.25, vmax=dead_cut+.25, axis=0, subset=list([col for col in ant_metrics_cols if 'dead' in col.lower()])) \
          .background_gradient(cmap='bwr_r', vmin=crossed_cut-.25, vmax=crossed_cut+.25, axis=0, subset=list([col for col in ant_metrics_cols if 'crossed' in col.lower()])) \
          .background_gradient(cmap='plasma', vmax=4, vmin=1, axis=None, subset=redcal_cols) \
          .applymap(lambda val: 'font-weight: bold' if val < dead_cut else '', subset=list([col for col in ant_metrics_cols if 'dead' in col.lower()])) \
          .applymap(lambda val: 'font-weight: bold' if val < crossed_cut else '', subset=list([col for col in ant_metrics_cols if 'crossed' in col.lower()])) \
          .applymap(lambda val: 'font-weight: bold' if val > mean_round_modz_cut else '', subset=z_score_cols) \
          .applymap(lambda val: 'color: red' if val > mean_round_modz_cut else '', subset=z_score_cols) \
          .bar(subset=list(bar_cols.keys()), vmin=0, vmax=1) \
          .format({col: '{:,.4f}'.format for col in z_score_cols}) \
          .format({col: '{:,.4f}'.format for col in ant_metrics_cols}) \
          .format({col: '{:,.2%}'.format for col in bar_cols}) \
          .applymap(lambda val: 'font-weight: bold', subset=['Ant']) \
          .set_table_styles([dict(selector="th",props=[('max-width', f'70pt')])])

Table 2: RTP Per-Antenna Metrics Summary Table¶

This admittedly very busy table incorporates summary information about all antennas in the array. Its columns depend on what information is available when the notebook is run (i.e. whether auto_metrics, ant_metrics, and/or redcal is done). These can be divided into 5 sections:

Basic Antenna Info: antenna number, node, and its a priori status.

Flag Fractions: Fraction of the night that an antenna was flagged for various reasons. Note that auto_metrics flags antennas for the whole night, so it'll be 0% or 100%.

auto_metrics Details: If auto_metrics is included, this section shows the modified Z-score signifying how much of an outlier each antenna and polarization is in each of four categories: bandpass shape, overall power, temporal variability, and temporal discontinuities. Bold red text indicates that this is a reason for flagging the antenna. It is reproduced from the auto_metrics_inspect.ipynb nightly notebook, so check that out for more details on the precise metrics.

ant_metrics Details: If ant_metrics is included, this section shows the average correlation-based metrics for antennas over the whole night. Low "dead ant" metrics (nominally below 0.4) indicate antennas not correlating with the rest of the array. Negative "crossed ant" metrics indicate antennas that show stronger correlations in their cross-pols than their same-pols, indicating that the two polarizations are probably swapped. Bold text indicates that the average is below the threshold for flagging.

redcal chi^2 Details: If redcal is included, this shows the median chi^2 per antenna. This would be 1 in an ideal array. Antennas are thrown out when they they are outliers in their median chi^2, usually greater than 4-sigma outliers in modified Z-score.

In [21]:
HTML(table.render())
Out[21]:
Ant Node A Priori Status Auto Metrics Flags Dead Fraction in Ant Metrics (Jee) Dead Fraction in Ant Metrics (Jnn) Crossed Fraction in Ant Metrics ee Shape Modified Z-Score nn Shape Modified Z-Score ee Power Modified Z-Score nn Power Modified Z-Score ee Temporal Variability Modified Z-Score nn Temporal Variability Modified Z-Score ee Temporal Discontinuties Modified Z-Score nn Temporal Discontinuties Modified Z-Score Average Dead Ant Metric (Jee) Average Dead Ant Metric (Jnn) Average Crossed Ant Metric
3 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 3.302315 -0.775620 -0.331428 -0.822916 -0.604101 -0.764743 -0.844329 1.913531 0.802851 0.518020 0.579071
4 N01 RF_maintenance 100.00% 0.00% 0.00% 0.00% -0.508512 4.671550 -0.444778 1.461919 -0.769471 -0.994033 -0.093765 -0.588002 0.818191 0.517126 0.584150
5 N01 digital_ok 100.00% 0.00% 0.00% 0.00% 0.093345 0.243584 -0.597923 4.960569 -1.426904 1.458792 0.431009 -1.246911 0.820591 0.528569 0.588893
7 N02 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
8 N02 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
9 N02 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
10 N02 digital_ok 0.00% 100.00% 100.00% 0.00% -1.329814 -0.656352 -0.588076 0.503748 0.274080 2.075135 2.057956 0.997595 0.070256 0.071175 0.014222
15 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 0.672683 1.140176 1.369220 0.662181 -0.732769 -0.715615 0.460531 0.162492 0.817880 0.526177 0.580775
16 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -0.440484 -1.038509 -0.529779 -0.358891 -0.304103 0.551256 6.093559 1.150376 0.820645 0.528889 0.573746
17 N01 digital_ok 0.00% 0.00% 0.00% 0.00% 0.099342 0.332493 0.736541 0.676141 0.825354 0.465386 3.481399 0.991428 0.820898 0.529233 0.585935
18 N01 RF_maintenance 100.00% 0.00% 100.00% 0.00% 6.680568 9.935981 4.089961 0.928596 7.316633 6.989249 21.244985 83.339514 0.797205 0.297261 0.635642
19 N02 digital_ok 100.00% 100.00% 100.00% 0.00% -0.909291 -1.160142 -0.916118 -0.695835 -0.283256 5.072301 4.156832 8.296958 0.044596 0.043969 0.003064
20 N02 digital_ok 0.00% 100.00% 100.00% 0.00% -1.728658 1.071918 -0.489308 0.428095 0.642158 1.750266 -0.001553 -0.915144 0.057569 0.050004 0.004497
21 N02 digital_ok 100.00% 100.00% 100.00% 0.00% 1.114766 -0.668658 0.697379 2.171253 -0.727920 0.785222 4.003178 0.576300 0.062222 0.056270 0.007689
27 N01 RF_maintenance 100.00% 100.00% 100.00% 0.00% 24.842043 26.194913 39.837316 40.659172 48.982357 45.024101 8.891619 7.124562 0.038956 0.042307 0.002226
28 N01 RF_maintenance 100.00% 0.00% 100.00% 0.00% 15.696895 28.391023 0.576442 1.664842 37.274911 40.803980 9.228993 55.310869 0.429618 0.181677 0.285008
29 N01 digital_ok 0.00% 0.00% 0.00% 0.00% -0.811766 -0.257464 0.581237 -0.531394 -0.396553 -0.127391 -0.253233 0.043539 0.824472 0.535259 0.578095
30 N01 digital_ok 100.00% 0.00% 0.00% 0.00% -0.403762 -0.103128 -0.459196 -0.837233 -0.355210 1.987433 7.236491 1.100022 0.815568 0.534331 0.576663
31 N02 digital_ok 0.00% 100.00% 100.00% 0.00% 0.386654 -0.792055 -0.811466 0.026045 2.360801 1.166774 0.555232 1.182994 0.057445 0.051731 0.005112
32 N02 RF_maintenance 100.00% 100.00% 100.00% 0.00% 41.707145 33.159303 2.898309 2.068498 11.267753 15.114198 35.271350 42.951242 0.076073 0.063473 0.003534
33 N02 RF_maintenance 100.00% 100.00% 100.00% 0.00% 0.131589 7.761617 -0.523185 -0.299241 34.092924 35.347631 148.911144 182.185848 0.055186 0.073854 0.021841
36 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 11.066510 8.427223 0.536569 -0.092161 0.871691 0.679118 0.961996 3.058709 0.816506 0.540964 0.559189
37 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 0.354567 1.150706 -0.672278 -0.215193 1.379085 -0.323334 0.464032 21.261328 0.826805 0.556291 0.559464
38 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 1.075708 -0.099563 -0.712038 -0.642800 0.141242 -0.177535 12.620605 5.202848 0.824174 0.562554 0.560811
40 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 0.117709 -0.269652 -0.265033 -0.481482 2.842618 -0.144254 -0.344776 -0.767305 0.066960 0.085669 0.019488
41 N04 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
42 N04 digital_ok 0.00% 100.00% 100.00% 0.00% -0.589425 0.475602 2.232004 1.063372 -0.590714 -1.055549 -0.814664 -0.669702 0.086930 0.093722 0.027963
45 N05 digital_ok 100.00% 0.00% 0.00% 0.00% 0.162480 0.612062 -0.820218 0.051157 -1.336178 0.005720 0.272498 14.181210 0.814680 0.517063 0.588931
46 N05 digital_ok 0.00% 0.00% 0.00% 0.00% -1.082649 -0.721218 0.896764 -0.735209 -0.491848 -1.105421 -0.010786 -0.309709 0.815852 0.506309 0.601617
50 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 38.501784 1.242156 3.511017 3.202584 7.605777 2.115725 2.274792 -1.222873 0.702549 0.552822 0.416825
51 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 1.478230 2.684612 -0.715361 -0.405165 2.566452 0.100709 0.491489 1.145510 0.822417 0.577973 0.540711
52 N03 RF_maintenance 100.00% 0.00% 0.00% 0.00% 8.826469 7.650326 1.103716 0.006731 2.723052 -1.407010 2.424307 1.818370 0.828729 0.580253 0.543124
53 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 2.293173 2.076123 -0.452757 0.048415 -0.637768 -0.105614 4.987265 16.653457 0.822847 0.587623 0.543927
54 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 1.357972 15.447347 1.626663 2.287286 1.295870 5.727232 0.563729 -0.082438 0.064946 0.073209 0.013262
55 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 2.896971 0.741068 -0.196837 1.452309 2.144480 -1.096515 10.053465 -0.301504 0.060618 0.055840 0.005305
56 N04 digital_ok 0.00% 100.00% 100.00% 0.00% -0.311477 0.650492 1.943179 1.870155 1.047993 -0.404390 -1.011707 0.679280 0.049560 0.060732 0.008072
57 N04 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
65 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 1.919196 0.731884 0.332046 1.030114 -0.200937 0.012712 -0.538800 1.203613 0.825742 0.557492 0.564955
66 N03 digital_ok 0.00% 0.00% 0.00% 0.00% 1.525870 0.931245 -0.612794 0.532906 0.546839 1.499041 -0.466711 2.233071 0.824800 0.582009 0.536401
67 N03 digital_ok 100.00% 0.00% 0.00% 0.00% -0.475162 -0.780287 0.813800 -0.504142 2.411748 2.129597 1.658996 6.374921 0.825130 0.597109 0.523539
68 N03 digital_ok 100.00% 0.00% 0.00% 0.00% 1.567081 1.027846 0.656463 8.919044 1.873120 5.339033 -0.157081 0.712369 0.822221 0.591011 0.525450
69 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 1.023112 -1.247919 0.383520 -0.010189 -0.429686 3.669230 -0.271155 2.820727 0.070005 0.063602 0.012120
70 N04 RF_maintenance 100.00% 100.00% 100.00% 0.00% 8.596313 -0.987261 0.824853 -0.616144 3.393499 -0.999831 1.135454 6.851849 0.071311 0.055595 0.006323
71 N04 digital_ok 0.00% 100.00% 100.00% 0.00% 0.676299 -0.432358 -0.771119 0.111116 2.345571 -0.892563 -0.386671 0.172118 0.067133 0.053930 0.005364
72 N04 digital_ok 100.00% 100.00% 100.00% 0.00% 3.869640 -0.951539 -0.332650 2.025250 4.323041 -0.567175 5.332582 -1.111612 0.086582 0.073236 0.015723
73 N05 digital_ok 100.00% 100.00% 0.00% 0.00% 24.062087 -0.150438 39.048206 3.721807 48.821368 2.471402 5.377118 -0.294839 0.035770 0.568014 0.289397
81 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 0.337222 1.590679 -0.557115 4.532236 2.021621 4.978538 0.951084 -0.916974 0.813443 0.538320 0.552881
82 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 5.490508 0.989447 1.896089 0.256720 0.704349 -0.873610 -0.234942 -0.598354 0.823091 0.562204 0.557831
83 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 1.721276 1.976640 2.711984 5.517362 1.003490 1.839593 -0.893805 -1.442627 0.825024 0.595026 0.531250
84 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 10.629806 11.535787 1.963192 1.034986 0.366545 1.216126 -0.486848 0.615419 0.830809 0.600979 0.522692
85 N08 digital_ok 0.00% 0.00% 0.00% 0.00% 0.578945 0.920453 0.763259 1.852152 -1.505742 -1.162741 -0.609819 -0.749105 0.817788 0.601683 0.533174
86 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 2.197533 4.685873 0.998254 -0.105191 1.635787 3.394852 -0.048792 -0.380855 0.818682 0.574764 0.531454
87 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 32.703543 12.764866 2.413893 1.289429 36.797680 0.419237 42.738862 -0.538473 0.734870 0.609422 0.446294
88 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 15.831281 13.136361 26.081105 23.296066 43.237149 32.454441 2.869210 2.259185 0.787014 0.580233 0.534818
90 N09 RF_maintenance 0.00% 0.00% 0.00% 0.00% 0.868852 0.310819 0.757193 3.297613 -0.277979 2.405825 0.228472 1.431660 0.825090 0.574739 0.560496
91 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 13.324931 14.572339 23.727793 24.511483 37.927952 36.435453 0.792029 3.510764 0.806583 0.554558 0.562975
92 N10 RF_maintenance 100.00% 100.00% 100.00% 0.00% 46.537724 63.728542 4.069330 5.609858 40.811805 54.390436 7.057482 30.464661 0.353684 0.254262 0.152680
93 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 0.614934 -0.136545 3.672744 0.931988 3.999640 -0.473538 2.622787 -0.977836 0.758649 0.481257 0.541350
94 N10 digital_ok 100.00% 0.00% 0.00% 0.00% -1.014022 -1.297624 -0.727914 -0.945261 -0.660514 3.629647 3.400309 10.484137 0.753946 0.457340 0.549535
98 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 1.618929 4.408798 1.381404 2.855589 0.947464 0.998754 0.573400 2.185840 0.812522 0.511658 0.578353
99 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 8.206355 1.047676 3.632061 0.617186 2.244269 0.685927 4.572136 -0.524750 0.817697 0.545888 0.561466
100 N07 digital_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
101 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 10.110294 11.184287 3.852856 0.183314 0.795427 -0.497540 7.232435 0.769262 0.831345 0.591590 0.545153
102 N08 RF_maintenance 100.00% 0.00% 48.63% 0.00% 26.611581 27.477988 1.560770 1.779323 711.141044 723.225961 11574.931365 11541.415004 0.757589 0.404838 0.560978
103 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 5.430455 11.102472 -0.159342 0.183606 -0.348490 0.178017 -0.291573 -0.466944 0.827941 0.609550 0.528070
104 N08 RF_maintenance 100.00% 0.00% 0.00% 0.00% 8.853526 84.029357 0.361730 13.672735 2.175410 1.730440 0.034603 -0.080228 0.832428 0.604997 0.548753
105 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 3.098958 6.699610 11.297572 15.825188 11.439025 17.939068 -1.040475 -1.092120 0.832097 0.614784 0.534880
106 N09 digital_ok 100.00% 0.00% 0.00% 0.00% -0.602825 13.756607 5.561900 23.587636 0.944584 33.177677 3.306526 2.844978 0.816066 0.589992 0.543056
107 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 14.693332 9.605213 23.303009 21.547274 35.925628 30.182228 0.526335 4.958649 0.817434 0.585006 0.532049
108 N09 digital_ok 100.00% 0.00% 0.00% 0.00% 2.906525 4.754708 16.535769 0.898731 2.147203 -0.888665 1.013769 0.871089 0.782632 0.592476 0.528349
109 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.835091 -0.007480 0.740172 0.612190 -1.033502 0.393463 -1.020567 -0.290278 0.770068 0.518812 0.533921
110 N10 RF_maintenance 100.00% 0.00% 0.00% 0.00% 42.138319 29.355459 3.193249 1.827633 3.119876 12.093307 -0.486709 0.275052 0.681260 0.437985 0.366177
111 N10 digital_ok 100.00% 0.00% 0.00% 0.00% -0.014833 1.910442 -0.526428 1.399427 0.159220 3.232217 0.016379 4.783827 0.764311 0.489218 0.537143
112 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.761529 -0.144399 -0.635034 1.019675 0.327517 -0.771069 -0.689917 -1.314160 0.753855 0.470569 0.547019
116 N07 digital_ok 0.00% 0.00% 0.00% 0.00% 0.292185 2.101001 0.091024 -0.672841 1.493029 -0.891154 3.190803 -0.867689 0.810660 0.507320 0.587776
117 N07 digital_ok 100.00% 0.00% 0.00% 0.00% 2.049196 1.230287 6.040814 6.291068 6.737155 3.667565 -1.150888 -1.584958 0.819803 0.529012 0.581796
118 N07 digital_ok 100.00% 0.00% 100.00% 0.00% 2.186042 29.029873 2.950854 35.174598 -0.926287 45.570619 -0.215537 3.069430 0.826122 0.049120 0.518145
119 N07 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
120 N08 RF_maintenance 100.00% 0.00% 100.00% 0.00% 20.248984 39.132412 1.391734 45.503788 35.098032 45.309927 4.116826 14.071655 0.463322 0.047119 0.305727
121 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 3.231482 6.985438 -0.439110 0.673932 0.143666 0.550885 63.119088 29.983795 0.834049 0.601673 0.531076
122 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 9.604653 8.902226 1.722419 1.622153 -0.133389 1.201413 -0.138706 -0.284811 0.839331 0.609753 0.532910
123 N08 digital_ok 100.00% 0.00% 0.00% 0.00% 8.698761 11.367688 0.268798 0.300757 -1.204304 -1.613234 0.569932 0.832701 0.836045 0.622189 0.527709
125 N09 RF_maintenance 100.00% 0.00% 0.00% 0.00% 4.500291 14.675817 12.672942 17.338923 12.827877 21.856215 -1.786159 3.552148 0.832233 0.599242 0.524358
126 N09 RF_maintenance 100.00% 0.00% 0.00% 0.00% 24.246590 2.889430 8.567628 7.302586 17.993949 5.827157 -0.063476 -1.520457 0.714050 0.601361 0.414428
127 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.082620 -0.310761 0.010189 -0.528570 0.483186 1.066386 0.038470 1.092256 0.769166 0.531642 0.527099
128 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -1.352573 2.522602 -0.409308 1.822125 0.354994 1.435053 0.061478 -0.946639 0.768753 0.519586 0.529714
129 N10 digital_ok 0.00% 0.00% 0.00% 0.00% -0.543030 -1.050806 -0.899709 -0.928814 0.553598 1.090882 -0.000447 0.255527 0.763291 0.502834 0.530283
130 N10 digital_ok 100.00% 0.00% 0.00% 0.00% 0.013998 -0.361424 0.409815 1.427967 3.132765 2.207168 0.675176 6.632760 0.753523 0.480015 0.536491
135 N12 digital_maintenance 0.00% 100.00% 100.00% 0.00% 0.187826 -0.022717 -0.805722 -0.833903 -0.012712 -0.649264 0.582925 -0.369614 0.090594 0.095336 0.025636
136 N12 digital_maintenance 100.00% 100.00% 100.00% 0.00% 2.291779 13.907137 -0.477459 0.807481 4.030179 2.736778 2.278397 3.467288 0.079510 0.092442 0.023506
137 N07 RF_maintenance 100.00% 0.00% 0.00% 0.00% 14.771131 6.747419 24.817210 16.036975 40.838561 10.070244 0.322144 1.583744 0.796349 0.519885 0.575975
138 N07 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
140 N13 digital_ok 100.00% 100.00% 100.00% 0.00% 22.534772 24.760660 38.895767 40.714191 48.977231 45.139376 4.657574 4.572101 0.038905 0.042743 0.002177
141 N13 digital_ok 100.00% 0.00% 0.00% 0.00% 2.556702 2.969637 0.482685 9.522345 1.952994 3.052109 1.468391 32.789249 0.831963 0.560143 0.551428
142 N13 digital_ok 100.00% 0.00% 100.00% 0.00% 26.191429 30.512535 1.889163 40.940310 41.652206 45.090219 5.549476 6.834801 0.501454 0.043936 0.265376
143 N14 digital_ok 0.00% 0.00% 0.00% 0.00% -0.770523 -0.755588 1.395475 1.177486 0.168586 -0.467078 -0.235727 -1.342941 0.825355 0.612769 0.515875
144 N14 digital_ok 100.00% 0.00% 0.00% 0.00% -0.891885 -0.709840 2.375411 -0.441658 -0.482175 1.730629 -0.252048 24.328511 0.834473 0.609740 0.530901
145 N14 RF_maintenance 100.00% 100.00% 100.00% 0.00% 25.104239 26.268427 40.098552 41.295345 49.069550 45.268313 8.031363 9.568767 0.034540 0.035573 -0.000525
150 N15 RF_maintenance 100.00% 100.00% 100.00% 0.00% 26.937441 29.214018 39.968816 42.130518 49.176933 45.284280 8.686394 9.545877 0.046499 0.048605 0.001313
155 N12 digital_maintenance 100.00% 100.00% 100.00% 0.00% 23.679907 23.345044 38.999537 40.373196 48.961391 45.085352 8.477381 9.207630 0.034619 0.035252 0.000756
156 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 0.357817 0.423599 1.516251 -0.161969 1.151882 0.433350 8.680598 18.048588 0.051446 0.060548 0.004783
157 N12 digital_ok 0.00% 100.00% 100.00% 0.00% 0.007480 -0.584359 -0.247831 3.546215 0.682953 0.704772 0.442329 -0.679970 0.066951 0.058560 0.005619
158 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 23.785336 -1.322335 39.854839 -0.208916 49.124525 1.583303 5.002922 12.463379 0.034369 0.062141 0.052404
160 N13 digital_ok 100.00% 100.00% 100.00% 0.00% 23.823709 24.275278 39.617422 40.775900 49.107870 45.173105 8.136608 9.395173 0.041180 0.044048 0.003733
161 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -0.573727 46.767091 0.140852 3.568694 -0.342235 4.507760 0.236950 -0.371639 0.819743 0.462170 0.534801
162 N13 digital_ok 0.00% 0.00% 0.00% 0.00% 0.349673 0.307854 -0.311391 -0.580375 2.696297 1.274075 1.703142 0.000447 0.827661 0.578311 0.552809
163 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 0.568436 0.044568 -0.131778 -0.771030 -1.227215 -0.315620 -0.274563 1.682189 0.824097 0.593439 0.530341
164 N14 digital_ok 0.00% 0.00% 0.00% 0.00% -1.165266 -1.311671 -0.845106 -0.732171 -1.133669 -0.284489 3.102420 1.610292 0.827460 0.593936 0.537264
165 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 0.199518 1.967452 7.418819 -0.652339 3.503238 -0.662102 -0.070589 0.081214 0.826253 0.596784 0.529294
166 N14 RF_maintenance 100.00% 0.00% 0.00% 0.00% 26.412084 1.989937 1.397560 1.631485 11.329413 9.619445 10.401595 12.238303 0.727194 0.573826 0.439880
167 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 38.203012 19.937845 17.688660 22.100281 34.053960 35.661441 4.900779 4.293258 0.651202 0.462908 0.354454
168 N15 RF_maintenance 100.00% 0.00% 0.00% 0.00% 11.884040 15.039681 22.043883 24.834871 33.729190 36.512764 -1.650510 2.292262 0.810076 0.544022 0.555032
169 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 14.138238 13.944232 24.287056 23.428817 39.010082 34.747988 0.695365 2.293756 0.807136 0.528624 0.566671
170 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 14.438864 12.071480 24.575115 22.360357 39.263803 30.987109 1.179582 2.064463 0.802011 0.529378 0.574127
176 N12 digital_ok 0.00% 100.00% 100.00% 0.00% 0.621108 -0.446415 -0.460702 0.821804 -0.120189 0.666029 -0.376210 1.952170 0.041753 0.068605 0.006306
177 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 1.051367 1.072025 1.203451 3.380727 -0.348177 2.479084 -0.050508 8.227384 0.067580 0.063561 0.006853
178 N12 digital_ok 0.00% 100.00% 100.00% 0.00% -0.964679 -1.064543 0.852431 -0.615597 -1.554411 -0.549548 -0.439987 -1.023105 0.078874 0.058451 0.008660
179 N12 digital_ok 100.00% 100.00% 100.00% 0.00% 0.421057 0.313596 -0.570132 -0.080555 8.117856 -1.329655 14.226338 -0.358397 0.071705 0.085692 0.019465
180 N13 RF_maintenance 100.00% 0.00% 100.00% 0.00% 0.293425 19.380742 0.856557 38.001862 0.762048 34.662745 -0.014999 6.633674 0.819402 0.259404 0.644031
181 N13 digital_ok 100.00% 100.00% 100.00% 0.00% 25.732457 60.965462 40.274811 7.330228 49.123572 47.261068 7.751448 5.867358 0.045147 0.309018 0.141609
182 N13 RF_maintenance 100.00% 0.00% 100.00% 0.00% 11.438567 18.412693 22.020084 36.067249 33.308063 33.218514 -1.718336 11.530607 0.811353 0.308908 0.605140
183 N13 digital_ok 100.00% 0.00% 0.00% 0.00% -1.407114 -1.012496 0.144734 -0.799066 -1.741055 -1.714453 -0.159423 7.549377 0.820405 0.566580 0.556624
184 N14 digital_ok 0.00% 0.00% 0.00% 0.00% 0.161540 0.049882 -0.124282 0.355315 -0.113056 0.461673 2.088135 -0.592594 0.819990 0.581163 0.539105
185 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 0.416993 0.246281 1.412345 0.855555 -0.094568 -0.333808 40.395364 -0.701874 0.822364 0.581825 0.542198
186 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 1.024921 -0.218000 3.843862 2.281641 0.933365 -0.827788 4.892949 0.120858 0.817217 0.577847 0.540008
187 N14 digital_ok 100.00% 0.00% 0.00% 0.00% 1.018049 1.212439 0.234772 1.158764 -0.053832 -0.823318 4.441230 -0.625749 0.818851 0.582560 0.533866
189 N15 digital_ok 100.00% 0.00% 0.00% 0.00% 3.765493 3.761849 0.331993 0.431053 1.388266 1.341506 2.579832 5.955987 0.814384 0.545967 0.575051
190 N15 digital_ok 100.00% 0.00% 100.00% 0.00% 58.927464 29.204004 4.756377 41.312234 22.050304 45.246022 2.495538 8.734999 0.664108 0.044792 0.443961
191 N15 digital_ok 0.00% 0.00% 0.00% 0.00% -0.944238 -0.175921 -0.607984 -0.855324 -0.439817 -0.589397 0.204108 -0.635217 0.816832 0.529243 0.600297
203 N18 RF_maintenance 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
205 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 22.056484 20.720972 16.062343 2.705453 26.852080 13.242288 32.578198 47.829783 0.818441 0.498446 0.590149
206 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 18.781516 19.179917 3.475008 10.237495 13.900493 13.801700 32.753251 34.075347 0.795892 0.521336 0.572442
207 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 22.734270 20.508592 17.521752 14.298343 28.460117 18.259612 12.401817 11.727098 0.797435 0.518042 0.565649
220 N18 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
221 N18 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
222 N18 RF_ok 100.00% 100.00% 100.00% 0.00% 42.016854 41.807751 inf inf 5484.073070 6402.085301 14037.116968 19417.702012 nan nan nan
223 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 19.583151 18.765016 8.781306 4.160384 9.797718 3.511396 -0.995015 46.952622 0.804560 0.484486 0.594718
224 N19 RF_ok 100.00% 0.00% 0.00% 0.00% 27.598732 27.767804 26.367360 26.005600 45.522129 40.716339 -1.399063 -1.169303 0.763568 0.462624 0.568433
241 N19 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
242 N19 RF_ok 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
243 N19 RF_ok 100.00% 100.00% 100.00% 0.00% 44.510739 44.295447 inf inf 7631.258157 7631.056814 23697.287746 23696.697636 nan nan nan
320 N03 dish_maintenance 100.00% 100.00% 100.00% 0.00% 30.902969 28.774777 27.530976 27.799440 48.764629 44.993157 14.395784 8.898971 0.053999 0.049530 0.004014
321 N02 not_connected 100.00% 100.00% 100.00% 0.00% 6.308227 4.268597 14.842320 13.395798 24.354757 20.077210 40.622880 40.403155 0.078656 0.061321 0.035025
323 N02 not_connected 100.00% 100.00% 100.00% 0.00% 23.930488 7.293914 1.301371 17.412496 16.824445 17.770314 4.928937 -0.704074 0.079574 0.062530 0.032702
324 N04 not_connected 100.00% 100.00% 100.00% 0.00% nan nan inf inf nan nan nan nan nan nan nan
329 N12 dish_maintenance 100.00% 100.00% 100.00% 0.00% 10.241725 4.014051 6.570808 12.444946 18.118785 13.980944 4.954816 -1.648675 0.099666 0.073611 0.041309
333 N12 dish_maintenance 100.00% 100.00% 100.00% 0.00% 5.316068 4.275046 0.032006 11.577389 7.121148 10.172190 7.090754 -0.852340 0.095823 0.075035 0.045883
In [22]:
# print ex_ants for easy copy-pasting to YAML file
proposed_ex_ants = [ant for i, ant in enumerate(ants) if np.any([col[i] > 0 for col in bar_cols.values()])]
print('ex_ants: [' + ", ".join(str(ant) for ant in proposed_ex_ants) + ']')
print(f'\nunflagged_ants: [{", ".join([str(ant) for ant in ants if ant not in proposed_ex_ants])}]')
# "golden" means no flags and good a priori status
golden_ants = ", ".join([str(ant) for ant in ants if ((ant not in proposed_ex_ants) and (a_priori_statuses[ant] in good_statuses.split(',')))])
print(f'\ngolden_ants: [{golden_ants}]')
ex_ants: [4, 5, 7, 8, 9, 10, 16, 18, 19, 20, 21, 27, 28, 30, 31, 32, 33, 36, 37, 38, 40, 41, 42, 45, 50, 52, 53, 54, 55, 56, 57, 67, 68, 69, 70, 71, 72, 73, 81, 82, 83, 84, 86, 87, 88, 91, 92, 93, 94, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 110, 111, 117, 118, 119, 120, 121, 122, 123, 125, 126, 130, 135, 136, 137, 138, 140, 141, 142, 144, 145, 150, 155, 156, 157, 158, 160, 161, 165, 166, 167, 168, 169, 170, 176, 177, 178, 179, 180, 181, 182, 183, 185, 186, 187, 189, 190, 203, 205, 206, 207, 220, 221, 222, 223, 224, 241, 242, 243, 320, 321, 323, 324, 329, 333]

unflagged_ants: [3, 15, 17, 29, 46, 51, 65, 66, 85, 90, 109, 112, 116, 127, 128, 129, 143, 162, 163, 164, 184, 191]

golden_ants: [3, 15, 17, 29, 46, 51, 65, 66, 85, 109, 112, 116, 127, 128, 129, 143, 162, 163, 164, 184, 191]
In [23]:
# write to csv
outpath = os.path.join(nb_outdir, f'rtp_summary_table_{JD}.csv')
print(f'Now saving Table 2 to a csv at {outpath}')
df.to_csv(outpath)
Now saving Table 2 to a csv at /home/obs/src/H6C_Notebooks/_rtp_summary_/rtp_summary_table_2459826.csv
In [24]:
# Load antenna positions
data_list = sorted(glob.glob(os.path.join(data_path, f'zen.{JD}.?????.sum.uvh5')))
hd = io.HERAData(data_list[len(data_list) // 2])

# Figure out where to draw the nodes
node_centers = {}
for node in sorted(set(list(nodes.values()))):
    if np.isfinite(node):
        this_node_ants = [ant for ant in ants + unused_ants if nodes[ant] == node]
        if len(this_node_ants) == 1:
            # put the node label just to the west of the lone antenna 
            node_centers[node] = hd.antpos[ant][node] + np.array([-14.6 / 2, 0, 0])
        else:
            # put the node label between the two antennas closest to the node center
            node_centers[node] = np.mean([hd.antpos[ant] for ant in this_node_ants], axis=0)
            closest_two_pos = sorted([hd.antpos[ant] for ant in this_node_ants], 
                                     key=lambda pos: np.linalg.norm(pos - node_centers[node]))[0:2]
            node_centers[node] = np.mean(closest_two_pos, axis=0)
In [25]:
def Plot_Array(ants, unused_ants, outriggers):
    plt.figure(figsize=(16,16))
    
    plt.scatter(np.array([hd.antpos[ant][0] for ant in hd.data_ants if ant in ants]), 
                np.array([hd.antpos[ant][1] for ant in hd.data_ants if ant in ants]), c='w', s=0)

    # connect every antenna to their node
    for ant in ants:
        if nodes[ant] in node_centers:
            plt.plot([hd.antpos[ant][0], node_centers[nodes[ant]][0]], 
                     [hd.antpos[ant][1], node_centers[nodes[ant]][1]], 'k', zorder=0)

    rc_color = '#0000ff'
    antm_color = '#ffa500'
    autom_color = '#ff1493'

    # Plot 
    unflagged_ants = []
    for i, ant in enumerate(ants):
        ant_has_flag = False
        # plot large blue annuli for redcal flags
        if use_redcal:
            if redcal_flagged_frac[ant] > 0:
                ant_has_flag = True
                plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=7 * (2 - 1 * float(not outriggers)), fill=True, lw=0,
                                                color=rc_color, alpha=redcal_flagged_frac[ant]))
                plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=6 * (2 - 1 * float(not outriggers)), fill=True, color='w'))
        
        # plot medium green annuli for ant_metrics flags
        if use_ant_metrics: 
            if ant_metrics_xants_frac_by_ant[ant] > 0:
                ant_has_flag = True
                plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=6 * (2 - 1 * float(not outriggers)), fill=True, lw=0,
                                                color=antm_color, alpha=ant_metrics_xants_frac_by_ant[ant]))
                plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=5 * (2 - 1 * float(not outriggers)), fill=True, color='w'))
        
        # plot small red annuli for auto_metrics
        if use_auto_metrics:
            if ant in auto_ex_ants:
                ant_has_flag = True                
                plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=5 * (2 - 1 * float(not outriggers)), fill=True, lw=0, color=autom_color)) 
        
        # plot black/white circles with black outlines for antennas
        plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=4 * (2 - 1 * float(not outriggers)), fill=True, color=['w', 'k'][ant_has_flag], ec='k'))
        if not ant_has_flag:
            unflagged_ants.append(ant)

        # label antennas, using apriori statuses if available
        try:
            bgc = matplotlib.colors.to_rgb(status_colors[a_priori_statuses[ant]])
            c = 'black' if (bgc[0]*0.299 + bgc[1]*0.587 + bgc[2]*0.114) > 186 / 256 else 'white'
        except:
            c = 'k'
            bgc='white'
        plt.text(hd.antpos[ant][0], hd.antpos[ant][1], str(ant), va='center', ha='center', color=c, backgroundcolor=bgc)

    # label nodes
    for node in sorted(set(list(nodes.values()))):
        if not np.isnan(node) and not np.all(np.isnan(node_centers[node])):
            plt.text(node_centers[node][0], node_centers[node][1], str(node), va='center', ha='center', bbox={'color': 'w', 'ec': 'k'})
    
    # build legend 
    legend_objs = []
    legend_labels = []
    
    # use circles for annuli 
    legend_objs.append(matplotlib.lines.Line2D([0], [0], marker='o', color='w', markeredgecolor='k', markerfacecolor='w', markersize=13))
    legend_labels.append(f'{len(unflagged_ants)} / {len(ants)} Total {["Core", "Outrigger"][outriggers]} Antennas Never Flagged')
    legend_objs.append(matplotlib.lines.Line2D([0], [0], marker='o', color='w', markerfacecolor='k', markersize=15))
    legend_labels.append(f'{len(ants) - len(unflagged_ants)} Antennas {["Core", "Outrigger"][outriggers]} Flagged for Any Reason')

    if use_auto_metrics:
        legend_objs.append(matplotlib.lines.Line2D([0], [0], marker='o', color='w', markeredgewidth=2, markeredgecolor=autom_color, markersize=15))
        legend_labels.append(f'{len([ant for ant in auto_ex_ants if ant in ants])} {["Core", "Outrigger"][outriggers]} Antennas Flagged by Auto Metrics')
    if use_ant_metrics: 
        legend_objs.append(matplotlib.lines.Line2D([0], [0], marker='o', color='w', markeredgewidth=2, markeredgecolor=antm_color, markersize=15))
        legend_labels.append(f'{np.round(np.sum([frac for ant, frac in ant_metrics_xants_frac_by_ant.items() if ant in ants]), 2)} Antenna-Nights on' 
                             f'\n{np.sum([frac > 0 for ant, frac in ant_metrics_xants_frac_by_ant.items() if ant in ants])} {["Core", "Outrigger"][outriggers]} Antennas '
                             'Flagged by Ant Metrics\n(alpha indicates fraction of time)')        
    if use_redcal:
        legend_objs.append(matplotlib.lines.Line2D([0], [0], marker='o', color='w', markeredgewidth=2, markeredgecolor=rc_color, markersize=15))
        legend_labels.append(f'{np.round(np.sum(list(redcal_flagged_frac.values())), 2)} Antenna-Nights on' 
                             f'\n{np.sum([frac > 0 for ant, frac in redcal_flagged_frac.items() if ant in ants])} {["Core", "Outrigger"][outriggers]} Antennas '
                             'Flagged by Redcal\n(alpha indicates fraction of time)')

    # use rectangular patches for a priori statuses that appear in the array
    for aps in sorted(list(set(list(a_priori_statuses.values())))):
        if aps != 'Not Found':
            legend_objs.append(plt.Circle((0, 0), radius=7, fill=True, color=status_colors[aps]))
            legend_labels.append(f'A Priori Status:\n{aps} ({[status for ant, status in a_priori_statuses.items() if ant in ants].count(aps)} {["Core", "Outrigger"][outriggers]} Antennas)')

    # label nodes as a white box with black outline
    if len(node_centers) > 0:
        legend_objs.append(matplotlib.patches.Patch(facecolor='w', edgecolor='k'))
        legend_labels.append('Node Number')

    if len(unused_ants) > 0:
        legend_objs.append(matplotlib.lines.Line2D([0], [0], marker='o', color='w', markerfacecolor='grey', markersize=15, alpha=.2))
        legend_labels.append(f'Anntenna Not In Data')
        
    
    plt.legend(legend_objs, legend_labels, ncol=2, fontsize='large', framealpha=1)
    
    if outriggers:
        pass
    else:
        plt.xlim([-200, 150])
        plt.ylim([-150, 150])        
       
    # set axis equal and label everything
    plt.axis('equal')
    plt.tight_layout()
    plt.title(f'Summary of {["Core", "Outrigger"][outriggers]} Antenna Statuses and Metrics on {JD}', size=20)    
    plt.xlabel("Antenna East-West Position (meters)", size=12)
    plt.ylabel("Antenna North-South Position (meters)", size=12)
    plt.xticks(fontsize=12)
    plt.yticks(fontsize=12)
    xlim = plt.gca().get_xlim()
    ylim = plt.gca().get_ylim()    
        
    # plot unused antennas
    plt.autoscale(False)    
    for ant in unused_ants:
        if nodes[ant] in node_centers:
            plt.plot([hd.antpos[ant][0], node_centers[nodes[ant]][0]], 
                     [hd.antpos[ant][1], node_centers[nodes[ant]][1]], 'k', alpha=.2, zorder=0)
        
        plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=4, fill=True, color='w', ec=None, alpha=1, zorder=0))
        plt.gca().add_artist(plt.Circle(tuple(hd.antpos[ant][0:2]), radius=4, fill=True, color='grey', ec=None, alpha=.2, zorder=0))
        if hd.antpos[ant][0] < xlim[1] and hd.antpos[ant][0] > xlim[0]:
            if hd.antpos[ant][1] < ylim[1] and hd.antpos[ant][1] > ylim[0]:
                plt.text(hd.antpos[ant][0], hd.antpos[ant][1], str(ant), va='center', ha='center', color='k', alpha=.2) 

Figure 1: Array Plot of Flags and A Priori Statuses¶

This plot shows all antennas, which nodes they are connected to, and their a priori statuses (as the highlight text of their antenna numbers). It may also show (depending on what is finished running):

  • Whether they were flagged by auto_metrics (red circle) for bandpass shape, overall power, temporal variability, or temporal discontinuities. This is done in a binary fashion for the whole night.
  • Whether they were flagged by ant_metrics (green circle) as either dead (on either polarization) or crossed, with the transparency indicating the fraction of the night (i.e. number of files) that were flagged.
  • Whether they were flagged by redcal (blue circle) for high chi^2, with the transparency indicating the fraction of the night (i.e. number of files) that were flagged.

Note that the last fraction does not include antennas that were flagged before going into redcal due to their a priori status, for example.

In [26]:
core_ants = [ant for ant in ants if ant < 320]
outrigger_ants = [ant for ant in ants if ant >= 320]
Plot_Array(ants=core_ants, unused_ants=unused_ants, outriggers=False)
if len(outrigger_ants) > 0:
    Plot_Array(ants=outrigger_ants, unused_ants=sorted(set(unused_ants + core_ants)), outriggers=True)

Metadata¶

In [27]:
from hera_qm import __version__
print(__version__)
from hera_cal import __version__
print(__version__)
2.0.3.dev44+g7d4aa18
3.1.4.dev9+gea58d1b
In [ ]: